﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using QuanLiThuVien.LinkModel;

namespace QuanLiThuVien.Source
{
    class SelectInfo
    {
        THUVIEN.Service1 serv = new THUVIEN.Service1();

        public void SelectPhieuMuon_MaDocGia(DataGrid m_dtPhieuMuon, string MaDocGia)
        {
            m_dtPhieuMuon.ItemsSource = serv.SelectPhieuMuon_MaDocGia(MaDocGia);
            List<DSPhieuMuon> ds = new List<DSPhieuMuon>();

            List<DSPhieuMuon> dsPhieuMuon = new List<DSPhieuMuon>();
            for (int i = 0; i < serv.SelectPhieuMuon_MaDocGia(MaDocGia).Length; i++)
            {
                DSPhieuMuon temp = new DSPhieuMuon();
                temp.MaPhieuMuon = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].MaPhieuMuon.ToString();
                temp.MaDocGia = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].MaDocGia.ToString();
                temp.HoTenDocGia = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].HoTenDocGia.ToString();
                temp.MaCuonSach = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].MaCuonSach.ToString();
                temp.TenDauSach = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].TenDauSach.ToString();
                temp.TenTheLoai = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].TenTheLoai.ToString();
                temp.NhaXuatBan = serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].NhaXuatBan.ToString();
                temp.NamXuatBan = Int32.Parse(serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].NamXuatBan.ToString());
                temp.NgayMuon = DateTime.Parse(serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].NgayMuon.ToString());
                temp.NgayPhaiTra = DateTime.Parse(serv.SelectPhieuMuon_MaDocGia(MaDocGia)[i].NgayPhaiTra.ToString());
                dsPhieuMuon.Add(temp);
            }
            m_dtPhieuMuon.ItemsSource = dsPhieuMuon;
        }

        public void SelectSach_TacGia(DataGrid m_dtThongTinSach, string HoTenTacGia)
        {
            m_dtThongTinSach.ItemsSource = serv.SelectSach_TacGia(HoTenTacGia);
            List<DSTimSach> ds = new List<DSTimSach>();

            List<DSTimSach> dsThongTinSach = new List<DSTimSach>();
            for (int i = 0; i < serv.SelectSach_TacGia(HoTenTacGia).Length; i++)
            {
                DSTimSach temp = new DSTimSach();
                temp.MaSach = serv.SelectSach_TacGia(HoTenTacGia)[i].MaSach.ToString();
                temp.MaDauSach = serv.SelectSach_TacGia(HoTenTacGia)[i].MaDauSach.ToString();
                temp.TenDauSach = serv.SelectSach_TacGia(HoTenTacGia)[i].TenDauSach.ToString();
                temp.HoTenTacGia = serv.SelectSach_TacGia(HoTenTacGia)[i].HoTenTacGia.ToString();
                temp.TenTheLoai = serv.SelectSach_TacGia(HoTenTacGia)[i].TenTheLoai.ToString();
                temp.NhaXuatBan = serv.SelectSach_TacGia(HoTenTacGia)[i].NhaXuatBan.ToString();
                temp.NamXuatBan = Int32.Parse(serv.SelectSach_TacGia(HoTenTacGia)[i].NamXuatBan.ToString());
                temp.DonGia = Int32.Parse(serv.SelectSach_TacGia(HoTenTacGia)[i].DonGia.ToString());
                dsThongTinSach.Add(temp);
            }

            m_dtThongTinSach.ItemsSource = dsThongTinSach;
        }

        public void SelectSach_TenDauSach(DataGrid m_dtThongTinSach, string TenDauSach)
        {
            m_dtThongTinSach.ItemsSource = serv.SelectSach_TenDauSach(TenDauSach);
            List<DSTimSach> ds = new List<DSTimSach>();

            List<DSTimSach> dsThongTinSach = new List<DSTimSach>();
            for (int i = 0; i < serv.SelectSach_TenDauSach(TenDauSach).Length; i++)
            {
                DSTimSach temp = new DSTimSach();
                temp.MaSach = serv.SelectSach_TenDauSach(TenDauSach)[i].MaSach.ToString();
                temp.MaDauSach = serv.SelectSach_TenDauSach(TenDauSach)[i].MaDauSach.ToString();
                temp.TenDauSach = serv.SelectSach_TenDauSach(TenDauSach)[i].TenDauSach.ToString();
                temp.HoTenTacGia = serv.SelectSach_TenDauSach(TenDauSach)[i].HoTenTacGia.ToString();
                temp.TenTheLoai = serv.SelectSach_TenDauSach(TenDauSach)[i].TenTheLoai.ToString();
                temp.NhaXuatBan = serv.SelectSach_TenDauSach(TenDauSach)[i].NhaXuatBan.ToString();
                temp.NamXuatBan = Int32.Parse(serv.SelectSach_TenDauSach(TenDauSach)[i].NamXuatBan.ToString());
                temp.DonGia = Int32.Parse(serv.SelectSach_TenDauSach(TenDauSach)[i].DonGia.ToString());
                dsThongTinSach.Add(temp);
            }

            m_dtThongTinSach.ItemsSource = dsThongTinSach;
        }

        public void SelectSach_NhaXuatBan(DataGrid m_dtThongTinSach, string NhaXuatBan)
        {
            m_dtThongTinSach.ItemsSource = serv.SelectSach_NhaXuatBan(NhaXuatBan);
            List<DSTimSach> ds = new List<DSTimSach>();

            List<DSTimSach> dsThongTinSach = new List<DSTimSach>();
            for (int i = 0; i < serv.SelectSach_NhaXuatBan(NhaXuatBan).Length; i++)
            {
                DSTimSach temp = new DSTimSach();
                temp.MaSach = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].MaSach.ToString();
                temp.MaDauSach = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].MaDauSach.ToString();
                temp.TenDauSach = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].TenDauSach.ToString();
                temp.HoTenTacGia = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].HoTenTacGia.ToString();
                temp.TenTheLoai = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].TenTheLoai.ToString();
                temp.NhaXuatBan = serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].NhaXuatBan.ToString();
                temp.NamXuatBan = Int32.Parse(serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].NamXuatBan.ToString());
                temp.DonGia = Int32.Parse(serv.SelectSach_NhaXuatBan(NhaXuatBan)[i].DonGia.ToString());
                dsThongTinSach.Add(temp);
            }

            m_dtThongTinSach.ItemsSource = dsThongTinSach;
        }

        public void SelectSach_TheLoai(DataGrid m_dtThongTinSach, string TenTheLoai)
        {
            m_dtThongTinSach.ItemsSource = serv.SelectSach_TheLoai(TenTheLoai);
            List<DSTimSach> ds = new List<DSTimSach>();

            List<DSTimSach> dsThongTinSach = new List<DSTimSach>();
            for (int i = 0; i < serv.SelectSach_TheLoai(TenTheLoai).Length; i++)
            {
                DSTimSach temp = new DSTimSach();
                temp.MaSach = serv.SelectSach_TheLoai(TenTheLoai)[i].MaSach.ToString();
                temp.MaDauSach = serv.SelectSach_TheLoai(TenTheLoai)[i].MaDauSach.ToString();
                temp.TenDauSach = serv.SelectSach_TheLoai(TenTheLoai)[i].TenDauSach.ToString();
                temp.HoTenTacGia = serv.SelectSach_TheLoai(TenTheLoai)[i].HoTenTacGia.ToString();
                temp.TenTheLoai = serv.SelectSach_TheLoai(TenTheLoai)[i].TenTheLoai.ToString();
                temp.NhaXuatBan = serv.SelectSach_TheLoai(TenTheLoai)[i].NhaXuatBan.ToString();
                temp.NamXuatBan = Int32.Parse(serv.SelectSach_TheLoai(TenTheLoai)[i].NamXuatBan.ToString());
                temp.DonGia = Int32.Parse(serv.SelectSach_TheLoai(TenTheLoai)[i].DonGia.ToString());
                dsThongTinSach.Add(temp);
            }

            m_dtThongTinSach.ItemsSource = dsThongTinSach;
        }

    }
}
